//
//  MovieListTableViewCell.m
//  豆瓣
//
//  Created by dllo on 15/10/27.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "MovieListTableViewCell.h"
#import "AppTools.h"
#import "UIImageView+WebCache.h"

@interface MovieListTableViewCell ()

@property (nonatomic, retain)UILabel *nameLabel;
@property (nonatomic, retain)UIImageView *headImageView;

@end

#define  FULLERAME [[UIScreen mainScreen]bounds]

@implementation MovieListTableViewCell

- (void)dealloc
{
    [_myMovie release];
    [_nameLabel release];
    [_headImageView release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        [self createSubViews];
        
    }
    return self;
}

- (void)createSubViews
{
    self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(100, 5, 200, 40)];
    self.nameLabel.text = @"hehe";
    [self.contentView addSubview:self.nameLabel];
    [_nameLabel release];
    
    
    self.headImageView = [[UIImageView alloc]initWithFrame:CGRectMake(5, 10, 80, 80*(FULLERAME.size.height/FULLERAME.size.width))];
    
    [self.contentView addSubview:self.headImageView];
    
    [self.headImageView release];
    
}

-(void)setMyMovie:(Movie *)myMovie
{
    if (_myMovie != myMovie) {
        [_myMovie release];
        _myMovie = [myMovie retain];
    }
    self.nameLabel.text = self.myMovie.movieName;
    
    NSURL *url = [NSURL URLWithString:self.myMovie.pic_url];
    
    [self.headImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"placeHoderImage.png"]];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
